MusicTalk = function() 
{ 
  this.track = new Track();
  this.article = new Article();
  this.loaderimg = 'http://static.ak.facebook.com/images/upload_progress.gif';
  
  window.mt = this;
}
MusicTalk.inherits(WebService);

MusicTalk.prototype.onLoading = function(target, text)
{
  target.innerHTML = text?text+'  ':'';
  var loader = document.createElement("img");
  loader.src = this.loaderimg; //'img/loader.gif';
  loader.style.verticalAlign = 'middle';
  loader.style.border = 'none';
  
  target.appendChild(loader);
}

MusicTalk.prototype.showForm = function(element)
{ 
  $(element).setStyle('height','');
  if($('track_summary')) $('track_summary').setStyle('display','none');
  $('song_form').setStyle('display','block');
}

MusicTalk.prototype.moreInfo = function(id, par_num, par_type)
{
  if(typeof par_type != 'string') var par_type = 'p';
  var par_num = parseInt(par_num);
  var show_info = true;
  var par = $$('#'+id+' '+par_type);
  
  for(var i=0; i<par.length; i++) {
       if((i+1) == par_num) {
          if($(id).getStyle('display') != 'none' && par[i].getStyle('display') != 'none'){
            $(id).setStyle('display','none');
            show_info = false;
            break;
           }
          par[i].setStyle('display', '');
        }
        else par[i].setStyle('display', 'none');
      }
  if(show_info) $(id).setStyle('display','');
}

MusicTalk.prototype.showError = function(errors, formId)
{
  var html = '';
  $$('.input_error').each(function(input,i){ input.removeClass('input_error'); });
  for (var i in errors) {
    if(errors.hasOwnProperty(i)) 
    {
     if(errors[i]) html +='<p><a href="javascript:$(\''+i+'\').focus();$(\''+i+'\').select()">'+errors[i]+'</a></p>'
     else html = '<p>Some error(s) were found. Please check the heighlighted fields</p>';
     $(i).addClass('input_error');
    }
  }
  if(html.length){
    var error_div = $('form_errors');
    if(! error_div){
      error_div = new Element('div',{
        'class': 'errors',
        'id': 'form_errors'}
      );
      
      error_div.injectBefore(formId);
    }
    error_div.setHTML(html);
    error_div.setStyle('display', 'block');
    //window.location ='#form_errors_a';
    
    return true;
  }
  else {
   if($('form_errors'))
     $('form_errors').setStyle('display', 'none');
   return  false;
  }
}
